package com.qf.dao.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.api.blog.dto.CatalogSortDTO;
import com.qf.api.blog.entity.WikiCatalogEntity;
import jakarta.validation.constraints.NotNull;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author sin
* @description 针对表【t_wiki_catalog(知识库目录表（两级结构）)】的数据库操作Mapper
* @createDate 2025-05-23 13:27:40
* @Entity com.qf.api.entity.TWikiCatalog
*/
@Mapper
public interface WikiCatalogMapper extends BaseMapper<WikiCatalogEntity> {

    Integer getMaxSort(@Param("wikiId") Long wikiId, @Param("parentId") Long parentId);

    @Update("UPDATE t_wiki_catalog SET sort = #{sort}, update_time = NOW() WHERE id = #{id}")
    void updateCatalogSort(@Param("id") Long id,@Param("sort") Integer sort);

    @Select("select id from t_wiki_catalog where parent_id=#{id}")
    List<Long> getChildIds(Long id);

    @Select("select article_id from t_wiki_catalog where parent_id = #{parentId}")
    List<Long> getArticleIdsByParentId(Long parentId);
}




